package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.CustomerAddress;
import com.weipai.springboot.model.CustomerBank;
import com.weipai.springboot.model.CustomerInvoice;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.CenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/23 11:44
 * 
 * app个人中心
 */
@RestController
public class CenterController {
    
    @Autowired
    CenterService centerService;

    /**
     * 新增收货地址
     * @param address
     * @return
     */
    @PostMapping("/center/saveAddress")
    public Response saveAddress(CustomerAddress address){
        return centerService.saveAddress(address);
    }

    /**
     * 修改收货地址
     * @param address
     * @return
     */
    @PostMapping("/center/updateAddress")
    public Response updateAddress(CustomerAddress address){
        return centerService.updateAddress(address);
    }

    /**
     * 获取用户的收货地址
     * @param id
     * @return
     */
    @GetMapping("/center/getAddressByCustomerId/{customerId}")
    public Response getAddressByCustomerId(@PathVariable("customerId") String id){
        return centerService.getAddressByCustomerId(id);
    }

    /**
     * 获取收货地址详细信息
     * @param id
     * @return
     */
    @GetMapping("/center/getAddressInfoById/{id}")
    public Response getAddressInfoById(@PathVariable("id") String id){
        return centerService.getAddressInfoById(id);
    }

    /**
     * 删除收货地址
     * @param id
     * @return
     */
    @GetMapping("/center/deleteAddressById/{id}")
    public Response deleteAddressById(@PathVariable("id") String id){
        return centerService.deleteAddressById(id);
    }

    /**
     * 设置地址为默认收货地址
     * @param id
     * @return
     */
    @GetMapping("/center/isDefaultAddress/{id}")
    public Response isDefaultAddress(@PathVariable("id") String id){
        return centerService.isDefaultAddress(id);
    }

    /**
     * 新增银行卡
     * @param customerBank
     * @return
     */
    @PostMapping("/center/saveBank")
    public Response saveBank(CustomerBank customerBank,String newCode,String oldCode){
        return centerService.saveBank(customerBank,newCode,oldCode);
    }

    /**
     * 根据  用户传的 银行卡号  返回是那个银行的卡, 银行logo
     * @param bankCard
     * @return
     */
    @RequestMapping("/center/getBankBybankCard")
    public Response getBankBybankCard( String bankCard){
        return centerService.getBankBybankCard(bankCard);
    }

    /**
     * 获取用户的银行卡
     * @param id
     * @return
     */
    @GetMapping("/center/getBankByCustomerId/{customerId}")
    public Response getBankByCustomerId(@PathVariable("customerId") String id){
        return centerService.getBankByCustomerId(id);
    }

    /**
     * 删除银行卡
     * @param id
     * @return
     */
    @GetMapping("/center/deleteBankById/{id}")
    public Response deleteBankById(@PathVariable("id") String id){
        return centerService.deleteBankById(id);
    }

    /**
     * 绑定支付宝账号
     * @param alipayAccount：支付宝账号
     * @param realName：真实姓名
     * @return
     */
    @PostMapping("/center/bindingAlipayAccount")
    public Response bindingAlipayAccount(String alipayAccount, String realName){
        return centerService.bindingAlipayAccount(alipayAccount, realName);
    }

    /**
     * 获取支付宝账号详细信息
     * @return
     */
    @GetMapping("/center/getAlipayAccountId")
    public Response getAlipayAccountCustomerId(){
        return centerService.getAlipayAccountCustomerId();
    }

    /**
     * 新增发票
     * @param customerInvoice
     * @return
     */
    @PostMapping("/center/saveInvoice")
    public Response saveInvoice(CustomerInvoice customerInvoice){
        return centerService.saveInvoice(customerInvoice);
    }

    /**
     * 修改发票
     * @return
     */
    @PostMapping("/center/updateInvoice")
    public Response updateInvoice(CustomerInvoice customerInvoice){
        return centerService.updateInvoice(customerInvoice);
    }

    /**
     * 获取用户的发票
     * @return
     */
    @GetMapping("/center/invoiceList")
    public Response invoiceList(String customerId){
        return centerService.invoiceList(customerId);
    }

    /**
     * 删除发票信息
     * @param id
     * @return
     */
    @GetMapping("/center/deleteInvoiceById/{id}")
    public Response deleteInvoiceById(@PathVariable("id") String id){
        return centerService.deleteInvoiceById(id);
    }


    /**
     *     获取 个人中心 信息
     * @return
     */
    @GetMapping("/center/getCenterById")
    public Response getCenterById(String customerId){
        return centerService.getCenterById(customerId);
    }


    
}
